package com.example.leetdemo.plan1;

import java.util.HashMap;
import java.util.Map;

public class Sword004 {
    // old
    public int singleNumber1(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < nums.length; i++) {
            if(map.containsKey(nums[i])) {
               map.put(nums[i], map.get(nums[i]) + 1);
               if (map.get(nums[i]) == 3) {
                   map.remove(nums[i]);
               }
            } else {
                map.put(nums[i], 1);
            }
        }
        int i = 0;
        for (Integer integer : map.keySet()) {
            i = integer;
        }
        return i;
    }


    public int singleNumber(int[] nums) {
        return 0;
    }

    public static void main(String[] args) {
        Sword004 sword004 = new Sword004();
        System.err.println(sword004.singleNumber(new int[] {0,1,0,1,0,1,99}));
    }
}
